import { Injectable } from '@angular/core';
import { Plugin, Cordova, IonicNativePlugin } from '@ionic-native/core';

/**
 * @name Package Manager
 * @description
 * This plugin find installed apps or all apps
 *
 * @usage
 * ```
 * import { PackageManager } from 'path-to/package-manager';
 *
 * constructor(private packageManager: PackageManager) { }
 *
 * ...
 *
 * this.packageManager.show(true)
 *   .then((res: any) => console.log(res))
 *   .catch((error: any) => console.error(error));
 *
 * ```
 */
@Plugin({
  pluginName: 'PackageManager',
  plugin: 'cordova-plugin-packagemanager', // npm package name, example: cordova-plugin-camera
  pluginRef: 'packagemanager',  //必须跟 platforms/android/assets/cordova_plugins.js中的clobbers的变量名称一致，区分大小写
  repo: 'https://github.com/fbsanches/cordova-plugin-packagemanager', // the github repository URL for the plugin
  platforms: ['Android'], // Array of platforms supported, example: ['Android', 'iOS']
})
@Injectable()
export class PackageManager extends IonicNativePlugin {

  /**
   * This function does something
   * @param installedApps {boolean} Some param to configure something
   * @return {Promise<any>} Returns a promise that resolves when something happens
   */
  @Cordova()
  show(installedApps: boolean): Promise<any> {
    return; // We add return; here to avoid any IDE / Compiler errors
  }

}